package com.joven.product.service.client.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 商品编辑参数
 * </p>
 *
 * @author Joven
 * @date 2022-01-06 18:21:27
 */
@Data
@ApiModel("商品编辑参数")
public class ProductEditDTO {
    @ApiModelProperty("ID")
    @NotNull(message = "id不能为空")
    private Long id;

    @ApiModelProperty("商品名称")
    private String name;

    @ApiModelProperty("商品价格")
    private BigDecimal price;

    @ApiModelProperty("0：待售，1：在售，2：下架")
    private Integer status;

    @ApiModelProperty("商品分类id")
    private Long categoryId;

    @ApiModelProperty("供应商id")
    private Long supplierId;

    @ApiModelProperty("商品属性")
    private List<@Valid ProductAttribute> attributes;

    @ApiModelProperty("商品详情")
    private ProductDetail detail;

    @ApiModelProperty("更新人id")
    private Long updateUser;

    @ApiModelProperty("更新人名称")
    private String updateUserName;

    @Data
    @ApiModel("商品详情DTO-商品详情")
    public static class ProductDetail {
        @ApiModelProperty("商品标题")
        @NotBlank(message = "商品标题不能为空")
        private String title;

        @ApiModelProperty("卖点")
        @NotBlank(message = "卖点不能为空")
        private String sellPoint;

        @ApiModelProperty("文案详情")
        @NotBlank(message = "文案详情不能为空")
        private String detail;
    }

    @Data
    @ApiModel("商品属性DTO")
    public static class ProductAttribute {
        @ApiModelProperty("属性名称")
        @NotBlank(message = "属性名称不能为空")
        private String name;

        @ApiModelProperty("属性值")
        @NotBlank(message = "属性值不能为空")
        private String value;

        @ApiModelProperty("属性类型：1基本属性，2销售属性")
        @NotNull(message = "属性类型不能为空")
        private Integer type;
    }
}